/**
 * @Author: easten
 * @Created: 2024-07-31 23:19:47
 * @Description: 产品设备配置
 *
 */
import { IotDeviceConfig } from "_common/entity";
import { createRequest, RequestMethod } from "_common/request";
import { AxiosInstance } from "axios";
export class ApiDeviceConfig {
  /**
   * @description 请求实例
   * @type {RequestMethod}
   * @memberof ApiDevice
   * */
  request: RequestMethod;
  url: string = "api/iot/device-config/";

  /**
   * @description 构造函数
   * @param config axios 配置
   */
  public constructor(instance: AxiosInstance) {
    // axios 实例化
    this.request = createRequest(instance);
  }
  /** 创建配置 */
  createDeviceConfig(data: any) {
    return this.request.post<boolean>(this.url + "", data);
  }

  /** 更新配置 */
  updateDeviceConfig(data: IotDeviceConfig) {
    return this.request.put<boolean>(this.url + "", data);
  }

  /** 删除配置 */
  deleteDeviceConfig(id: number) {
    return this.request.delete<boolean>(this.url + "" + id);
  }

  /** 获取配置信息 */
  getDeviceConfigInfo(id: number) {
    return this.request.get<IotDeviceConfig>(this.url + "get-attr", { id });
  }

  /** 获取配置列表 */
  getDeviceConfigList() {
    return this.request.get<IotDeviceConfig[]>(this.url + "get-list");
  }

  getDeviceConfig(code: string) {
    return this.request.get<IotDeviceConfig>(this.url + "get-config/" + code);
  }

  // 获取配置分页列表
  getPageList(params: any) {
    return this.request.get<any>(this.url + "get-page", params);
  }
}
